<?php

$line = array('ACCOUNT_NUMBER', 'MAC_ADDRESS', 'SERIAL_NO', 'PROBLEM');
$csv->addRow($line);

foreach($result AS $r)
  {
        
    $line = array($r['c']['account_number'], $r['c']['mac_address'], $r['c']['serial_no'], $r['p']['name']);
    $csv->addRow($line);
  }

$datum = date("d.m.Y");
$end = ".csv";
$title = "Export_Blacklist_BadPayers_".$datum.".csv";
echo $csv->render($title);
?>